# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# PINS test functions that can be run on any infrastructure that supports ThinKit.

package(
    default_visibility = ["//visibility:public"],
    licenses = ["notice"],
)

cc_library(
    name = "json_utils",
    srcs = ["json_utils.cc"],
    hdrs = [
        "json_utils.h",
    ],
    copts = ["-fexceptions"],
    features = ["-use_header_modules"],  # Incompatible with -fexceptions.
    deps = [
        "@com_github_google_glog//:glog",
        "//gutil/gutil:status",
        "@com_github_nlohmann_json//:nlohmann_json",
        "@com_google_absl//absl/container:btree",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/container:flat_hash_set",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_jsoncpp//:json",
    ],
)

cc_test(
    name = "json_utils_test",
    srcs = ["json_utils_test.cc"],
    deps = [
        ":json_utils",
        "//gutil/gutil:status_matchers",
        "@com_github_nlohmann_json//:nlohmann_json",
        "@com_google_absl//absl/strings",
        "@com_google_googletest//:gtest_main",
        "@com_jsoncpp//:json",
    ],
)

cc_library(
    name = "json_test_utils",
    testonly = True,
    srcs = ["json_test_utils.cc"],
    hdrs = ["json_test_utils.h"],
    deps = [
        ":json_utils",
        "@com_github_nlohmann_json//:nlohmann_json",
        "@com_google_absl//absl/status:statusor",
        "@com_google_googletest//:gtest",
    ],
)

cc_test(
    name = "json_test_utils_test",
    srcs = ["json_test_utils_test.cc"],
    deps = [
        ":json_test_utils",
        "@com_google_absl//absl/strings",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_library(
    name = "generic_testbed_utils",
    testonly = True,
    srcs = ["generic_testbed_utils.cc"],
    hdrs = ["generic_testbed_utils.h"],
    deps = [
        "//gutil/gutil:status",
        "//lib/gnmi:gnmi_helper",
        "//lib/validator:validator_lib",
        "//thinkit:generic_testbed",
        "//thinkit:switch",
        "//thinkit/proto:generic_testbed_cc_proto",
        "@com_github_otg_models//:otg_cc_proto",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/types:span",
    ],
)

cc_test(
    name = "generic_testbed_utils_test",
    srcs = ["generic_testbed_utils_test.cc"],
    deps = [
        ":generic_testbed_utils",
        "//gutil/gutil:proto_matchers",
        "//gutil/gutil:status_matchers",
        "//gutil/gutil:testing",
        "//thinkit:generic_testbed",
        "//thinkit:mock_control_device",
        "//thinkit:mock_generic_testbed",
        "//thinkit:mock_switch",
        "//thinkit/proto:generic_testbed_cc_proto",
        "@com_github_gnmi//proto/gnmi:gnmi_cc_grpc_proto",
        "@com_github_grpc_grpc//:grpc++_public_hdrs",
        "@com_github_otg_models//:otg_cc_proto",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/memory",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_googletest//:gtest_main",
    ],
)
